home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
8174
/
8174.xpi
/
chrome
/
antbar.jar
/
content
/
grabber
/
grabber.js
< prev
next >
Wrap
Text File
|
2009-12-30
|
3KB
|
109 lines
//
// grabber.js
// firefox
//
// Created by Zak on 2008-07-14.
// Contributor Brian King (http://briks.si)
// Copyright 2008-2009 Ant.com. All rights reserved.
//
var AntGrabber = {
queryObserver: null,
htmlParser: null,
state: false,
isStarted: function () {
var self = AntGrabber;
return self.state;
},
/**
* This method starts observing firefox requests and set a onload event
* to be able to parse the current page and detect flvs
*/
init: function ()
{
var self = AntGrabber;
self.queryObserver = new AntQueryObserver();
self.htmlParser = new AntHtmlParser();
self.start();
},
/**
* Initialize the HTML Parser class
*/
initHtmlParser: function (event)
{
var self = AntGrabber;
//return function (event) {
if (event.originalTarget instanceof HTMLDocument)
{
var currentDoc = event.originalTarget;
var rootDoc = currentDoc;
if (event.originalTarget.defaultView.frameElement)
{
while (rootDoc.defaultView.frameElement)
rootDoc = rootDoc.defaultView.frameElement.ownerDocument;
// AntLib.toLog('Frame: ' + currentDoc.location.href);
}
else
{
// AntLib.toLog('RootPage: ' + currentDoc.location.href);
}
//that.htmlParser.onShowPage(currentDoc, rootDoc);
self.htmlParser.onShowPage(currentDoc, rootDoc);
}
//}
},
/**
* Start the grabber
*/
start: function ()
{
var self = AntGrabber;
var observerService = AntLib.CCSV("@mozilla.org/observer-service;1", "nsIObserverService");
/*
window.addEventListener("load", function () {
gBrowser.addEventListener("DOMContentLoaded", AntGrabber.initHtmlParser(), true);
}, false);
*/
observerService.addObserver(self.queryObserver, "http-on-examine-response", false);
observerService.addObserver(self.queryObserver, "http-on-examine-cached-response", false);
self.state = true;
},
/**
* Called when a new flv is found
* @param flvLink The found flv object
*/
foundFlvLink: function (flvLink)
{
AntLib.toLog("AntGrabber: New video found [Origin: "+flvLink.origin+", URL: "+flvLink.url+", Name: "+flvLink.name+"]");
var doc = flvLink.doc;
if (typeof(doc.__antflv__) == 'undefined')
doc.__antflv__ = new Array();
if (AntPrefs.isNotification)
AntFlvList.notify(flvLink);
/**
* The video list is odered by flv score :
*/
var pos;
for (pos in doc.__antflv__)
if (doc.__antflv__[pos].score <= flvLink.score)
break;
doc.__antflv__.splice(pos, 0, flvLink);
AntFlvUi.updateDownloadButton();
}
};